package com.sanyang.pda.presenter;


import com.sanyang.pda.bean.StorageInfoBean;
import com.sanyang.pda.contract.HomeContract;
import com.sanyang.pda.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import io.reactivex.functions.Consumer;

public class HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter {

    @Override
    public void storageUseInfo() {
        NetUtils.geApi().storageUseInfo()
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<StorageInfoBean>>() {
                    @Override
                    public void accept(BaseAppEntity<StorageInfoBean> storageInfoBeanBaseAppEntity) throws Exception {
                        getView().setStorageUseInfo(storageInfoBeanBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });

    }
}
